#ifndef RADIO_MANAGER_H
#define RADIO_MANAGER_H

#include <gtk/gtk.h>
#include <string>

// UI更新数据结构
struct UpdateUIData {
    std::string cw;
    int index;
};

class RadioManager {
public:
    static void on_radio_config_clicked(GtkWidget *widget, gpointer data);
    static void on_station_config_clicked(GtkWidget *widget, gpointer data);
    static void on_direct_line_config_clicked(GtkWidget *widget, gpointer data);
    static void on_cw_config_clicked(GtkWidget *widget, gpointer data);
    static void save_current_config();
    
    // CW port management functions
    static bool is_cw_port_open();
    static int open_cw_port();
    static void close_cw_port();
    static void send_cw(const std::string& cw);
    static void sendThread(const std::string& cw);
    static void stopSendThread();
private:
    static void update_radio_config_from_ui(GtkBuilder *builder);
    static bool set_rts(bool state);
    static int set_dtr(int fd, int state);
    static void translateStrToCw(const std::string& str, std::string& cw);
};

#endif // RADIO_MANAGER_H